/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.actionsystem.gdp.dao;

import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

/**
 *
 * @author Usuario
 */
public class ConexaoSingleton {

    private static ConexaoSingleton conexao = null;
    private static EntityManagerFactory emf = null;
    private static EntityManager em;
    
    private ConexaoSingleton() throws ClassNotFoundException {
      emf = Persistence.createEntityManagerFactory("GDPPU");
      em = emf.createEntityManager();
    }

    public static EntityManager getConexao() {
        try {
            if (conexao == null) {
                conexao = new ConexaoSingleton();
            }
        } catch (Exception ex) {
           ex.printStackTrace();
        }
        return em;
    }
}
